home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 May / PC Answers CD-ROM 7 (Future Publishing) (May 1995).iso / vbits / code / cert / trk3_eg / security / security.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-11-16  |  6.1 KB  |  218 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   4035
  5.    ClientLeft      =   1905
  6.    ClientTop       =   2055
  7.    ClientWidth     =   4365
  8.    Height          =   4440
  9.    Left            =   1845
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   4035
  12.    ScaleWidth      =   4365
  13.    Top             =   1710
  14.    Width           =   4485
  15.    Begin TextBox txtPWD2 
  16.       Height          =   285
  17.       Left            =   2640
  18.       PasswordChar    =   "#"
  19.       TabIndex        =   12
  20.       Text            =   "bob"
  21.       Top             =   1680
  22.       Width           =   1335
  23.    End
  24.    Begin TextBox txtUID2 
  25.       Height          =   285
  26.       Left            =   2640
  27.       TabIndex        =   11
  28.       Text            =   "Bob"
  29.       Top             =   960
  30.       Width           =   1335
  31.    End
  32.    Begin TextBox txtPWD1 
  33.       Height          =   285
  34.       Left            =   360
  35.       PasswordChar    =   "#"
  36.       TabIndex        =   7
  37.       Text            =   "mary"
  38.       Top             =   1680
  39.       Width           =   1335
  40.    End
  41.    Begin TextBox txtUID1 
  42.       Height          =   285
  43.       Left            =   360
  44.       TabIndex        =   6
  45.       Text            =   "Mary"
  46.       Top             =   960
  47.       Width           =   1335
  48.    End
  49.    Begin CommandButton Command2 
  50.       Caption         =   "Open Db2"
  51.       Height          =   495
  52.       Left            =   2640
  53.       TabIndex        =   3
  54.       Top             =   3120
  55.       Width           =   1215
  56.    End
  57.    Begin CommandButton Command1 
  58.       Caption         =   "Open Db"
  59.       Height          =   495
  60.       Left            =   360
  61.       TabIndex        =   2
  62.       Top             =   3120
  63.       Width           =   1215
  64.    End
  65.    Begin TextBox Text2 
  66.       DataSource      =   "Data2"
  67.       Height          =   285
  68.       Left            =   2640
  69.       TabIndex        =   1
  70.       Top             =   2280
  71.       Width           =   1215
  72.    End
  73.    Begin TextBox Text1 
  74.       DataSource      =   "Data1"
  75.       Height          =   285
  76.       Left            =   360
  77.       TabIndex        =   0
  78.       Top             =   2280
  79.       Width           =   1215
  80.    End
  81.    Begin Data Data2 
  82.       Caption         =   "Data2"
  83.       Connect         =   ""
  84.       DatabaseName    =   ""
  85.       Exclusive       =   0   'False
  86.       Height          =   270
  87.       Left            =   2640
  88.       Options         =   0
  89.       ReadOnly        =   0   'False
  90.       RecordSource    =   ""
  91.       Top             =   2760
  92.       Width           =   1140
  93.    End
  94.    Begin Data Data1 
  95.       Caption         =   "Data1"
  96.       Connect         =   ""
  97.       DatabaseName    =   ""
  98.       Exclusive       =   0   'False
  99.       Height          =   270
  100.       Left            =   360
  101.       Options         =   0
  102.       ReadOnly        =   0   'False
  103.       RecordSource    =   ""
  104.       Top             =   2760
  105.       Width           =   1140
  106.    End
  107.    Begin Label Label6 
  108.       Caption         =   "Password"
  109.       Height          =   255
  110.       Left            =   2640
  111.       TabIndex        =   13
  112.       Top             =   1440
  113.       Width           =   1215
  114.    End
  115.    Begin Label Label5 
  116.       Caption         =   "User Name"
  117.       Height          =   255
  118.       Left            =   2640
  119.       TabIndex        =   10
  120.       Top             =   720
  121.       Width           =   1215
  122.    End
  123.    Begin Label Label4 
  124.       Caption         =   "Password"
  125.       Height          =   255
  126.       Left            =   360
  127.       TabIndex        =   9
  128.       Top             =   1440
  129.       Width           =   1215
  130.    End
  131.    Begin Label Label3 
  132.       Caption         =   "User Name"
  133.       Height          =   255
  134.       Left            =   360
  135.       TabIndex        =   8
  136.       Top             =   720
  137.       Width           =   1215
  138.    End
  139.    Begin Label Label2 
  140.       Caption         =   "Label2"
  141.       Height          =   255
  142.       Left            =   2640
  143.       TabIndex        =   5
  144.       Top             =   240
  145.       Width           =   1695
  146.    End
  147.    Begin Label Label1 
  148.       Caption         =   "Label1"
  149.       Height          =   255
  150.       Left            =   360
  151.       TabIndex        =   4
  152.       Top             =   240
  153.       Width           =   1695
  154.    End
  155. Option Explicit
  156. Dim dbname1 As String
  157. Dim dbname2 As String
  158. Dim myPath As String
  159. 'WritePrivateProfileString
  160. Declare Function WritePrivateProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lplFileName As String) As Integer
  161. Sub Command1_Click ()
  162. On Error GoTo ErrPermissions2
  163. SetDefaultWorkspace txtUID1.Text, txtPWD1.Text
  164. data1.DatabaseName = myPath & dbname1
  165. data1.RecordSource = "tblStates"
  166. text1.DataField = "sState_cd"
  167. data1.Refresh
  168. Exit Sub
  169. ErrPermissions2:
  170. Select Case Err
  171. Case 3033
  172.     MsgBox "You do not have permission to this database"
  173.     Exit Sub
  174. Case 3029
  175.     MsgBox Error$
  176.     Exit Sub
  177. Case Else
  178.     MsgBox "An unexpected error has occurred!" & Chr(10) & Err & Chr(10) & Error$
  179.     End
  180. End Select
  181. End Sub
  182. Sub Command2_Click ()
  183. On Error GoTo ErrPermissions
  184. SetDefaultWorkspace txtUID2.Text, txtPWD2.Text
  185. data2.DatabaseName = myPath & dbname2
  186. data2.RecordSource = "tblStates"
  187. text2.DataField = "szState_nm"
  188. data2.Refresh
  189. Exit Sub
  190. ErrPermissions:
  191. Select Case Err
  192. Case 3033
  193.     MsgBox "You do not have permission to this database"
  194.     Exit Sub
  195. Case 3029
  196.     MsgBox Error$
  197.     Exit Sub
  198. Case Else
  199.     MsgBox "An unexpected error has occurred!" & Chr(10) & Err & Chr(10) & Error$
  200.     End
  201. End Select
  202. End Sub
  203. Sub Form_Load ()
  204. Dim MDA As String
  205. Dim rc As Integer
  206. Dim INInm As String
  207. myPath = APP.Path & IIf(Right$(APP.Path, 1) = "\", "", "\")
  208. 'INInm = myPath & APP.EXEName & ".ini"
  209. INInm = "C:\aaamarch\msu\vbmsu\example\security\security.INI"
  210. MDA = myPath & "System.MDA"
  211. rc = WritePrivateProfileString("Options", "Systemdb", MDA, myPath & INInm)
  212. SetDataAccessOption 1, INInm
  213. dbname1 = "MARY.MDB"
  214. dbname2 = "BOB.MDB"
  215. label1.Caption = dbname1
  216. label2.Caption = dbname2
  217. End Sub
  218.